package com.boliq.lol.adapter;

import com.boliq.lol.base.BaseVpAdapter;
import com.boliq.lol.bean.NewsTypeBean;
import com.boliq.lol.ui.news.ActivityFragment;
import com.boliq.lol.ui.news.GameFragment;
import com.boliq.lol.ui.news.NewsArticleFragment;
import com.boliq.lol.ui.news.RecommendFragment;
import com.boliq.lol.ui.news.ActivityFragment;
import com.boliq.lol.ui.news.YunDingFragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;


public class NewsVpAdapter extends BaseVpAdapter<NewsTypeBean> {

    public NewsVpAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    @Override
    protected Fragment createFragment(int position) {
        Fragment fragment = null;
        NewsTypeBean bean = getData(position);
        if (bean.getType() == NewsTypeBean.TYPE_ARTICLE) {
            fragment = new NewsArticleFragment();
        }
        if(position==1&bean.getType() == NewsTypeBean.TYPE_ARTICLE){
            fragment=new RecommendFragment();
        }
        if(position==2&bean.getType() == NewsTypeBean.TYPE_ARTICLE){
            fragment=new GameFragment();
        }
        if(position==3&bean.getType() == NewsTypeBean.TYPE_ARTICLE){
            fragment=new YunDingFragment();
        }
        if(position==7&bean.getType() == NewsTypeBean.TYPE_ARTICLE){
            fragment=new ActivityFragment();
        }
        return fragment;


    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return getData(position).getTitle();
    }
}
